<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>珠峰架构师成长计划</title>
    <link rel="stylesheet" type="text/css" href="../static/css/main.css">
</head>
<body>
<div class="nav">
    <div class="logo">
        
            珠峰架构师成长计划
        
    </div>
<ul><li><a href="../index.html">0.Async</a></li><li><a href="../html/0.editor.html">0.editor</a></li><li><a href="../html/0.module.html">0.module</a></li><li><a href="../html/1.ES2015.html">1.ES2015</a></li><li><a href="../html/2.Promise.html">2.Promise</a></li><li><a href="../html/3.Node.html">3.Node</a></li><li><a href="../html/4.NodeInstall.html">4.NodeInstall</a></li><li><a href="../html/5.REPL.html">5.REPL</a></li><li><a href="../html/6.NodeCore.html">6.NodeCore</a></li><li><a href="../html/7.module&NPM.html">7.module&NPM</a></li><li><a href="../html/8.Encoding.html">8.Encoding</a></li><li><a href="../html/9.Buffer.html">9.Buffer</a></li><li><a href="../html/10.fs.html">10.fs</a></li><li><a href="../html/11.Stream-1.html">11.Stream-1</a></li><li><a href="../html/11.Stream-2.html">11.Stream-2</a></li><li><a href="../html/11.Stream-3.html">11.Stream-3</a></li><li><a href="../html/11.Stream-4.html">11.Stream-4</a></li><li><a href="../html/12-Network-2.html">12-Network-2</a></li><li><a href="../html/12.NetWork-3.html">12.NetWork-3</a></li><li><a href="../html/12.Network-1.html">12.Network-1</a></li><li><a href="../html/13.tcp.html">13.tcp</a></li><li><a href="../html/14.http-1.html">14.http-1</a></li><li><a href="../html/14.http-2.html">14.http-2</a></li><li><a href="../html/15.compress.html">15.compress</a></li><li><a href="../html/16.crypto.html">16.crypto</a></li><li><a href="../html/17.process.html">17.process</a></li><li class="active"><a href="../html/18.yargs.html">18.yargs</a></li><li><a href="../html/19.cache.html">19.cache</a></li><li><a href="../html/20.action.html">20.action</a></li><li><a href="../html/21.https.html">21.https</a></li><li><a href="../html/22.cookie.html">22.cookie</a></li><li><a href="../html/23.session.html">23.session</a></li><li><a href="../html/24.express-1.html">24.express-1</a></li><li><a href="../html/24.express-2.html">24.express-2</a></li><li><a href="../html/24.express-3.html">24.express-3</a></li><li><a href="../html/24.express-4.html">24.express-4</a></li><li><a href="../html/25.koa-1.html">25.koa-1</a></li><li><a href="../html/26.webpack-1-basic.html">26.webpack-1-basic</a></li><li><a href="../html/26.webpack-2-optimize.html">26.webpack-2-optimize</a></li><li><a href="../html/26.webpack-3.tapable.html">26.webpack-3.tapable</a></li><li><a href="../html/26.webpack-4-AST.html">26.webpack-4-AST</a></li><li><a href="../html/26.webpack-5-source.html">26.webpack-5-source</a></li><li><a href="../html/26.webpack-6-loader.html">26.webpack-6-loader</a></li><li><a href="../html/26.webpack-7-plugin.html">26.webpack-7-plugin</a></li><li><a href="../html/26.webpack-8-hand.html">26.webpack-8-hand</a></li><li><a href="../html/27.react-1.html">27.react-1</a></li><li><a href="../html/27.react-2.html">27.react-2</a></li><li><a href="../html/27.react-3.html">27.react-3</a></li><li><a href="../html/27.react-4-immutable.html">27.react-4-immutable</a></li><li><a href="../html/27.react-5-react-dom-diff.html">27.react-5-react-dom-diff</a></li><li><a href="../html/27.react-6.html">27.react-6</a></li><li><a href="../html/28.react-mobx.html">28.react-mobx</a></li><li><a href="../html/28.redux-0.html">28.redux-0</a></li><li><a href="../html/28.redux-1.html">28.redux-1</a></li><li><a href="../html/28.redux-2-中间件.html">28.redux-2-中间件</a></li><li><a href="../html/28.redux-3-saga.html">28.redux-3-saga</a></li><li><a href="../html/28.redux-jwt-back.html">28.redux-jwt-back</a></li><li><a href="../html/28.redux-jwt-front.html">28.redux-jwt-front</a></li><li><a href="../html/29.mongodb-1.html">29.mongodb-1</a></li><li><a href="../html/29.mongodb-2.html">29.mongodb-2</a></li><li><a href="../html/29.mongodb-3.html">29.mongodb-3</a></li><li><a href="../html/29.mongodb-4.html">29.mongodb-4</a></li><li><a href="../html/29.mongodb-5.html">29.mongodb-5</a></li><li><a href="../html/29.mongodb-6.html">29.mongodb-6</a></li><li><a href="../html/30.cms-1-mysql.html">30.cms-1-mysql</a></li><li><a href="../html/30.cms-2-mysql.html">30.cms-2-mysql</a></li><li><a href="../html/30.cms-3-mysql.html">30.cms-3-mysql</a></li><li><a href="../html/30.cms-4-egg.html">30.cms-4-egg</a></li><li><a href="../html/30.cms-5-api.html">30.cms-5-api</a></li><li><a href="../html/30.cms-6-roadhog.html">30.cms-6-roadhog</a></li><li><a href="../html/30.cms-7-umi.html">30.cms-7-umi</a></li><li><a href="../html/30.cms-8-dva.html">30.cms-8-dva</a></li><li><a href="../html/30.cms-9-dva.html">30.cms-9-dva</a></li><li><a href="../html/30.cms-10-front.html">30.cms-10-front</a></li><li><a href="../html/30.cms-11-deploy.html">30.cms-11-deploy</a></li><li><a href="../html/33.redis.html">33.redis</a></li><li><a href="../html/34.unittest.html">34.unittest</a></li><li><a href="../html/35.jwt.html">35.jwt</a></li><li><a href="../html/36.websocket-1.html">36.websocket-1</a></li><li><a href="../html/36.websocket-2.html">36.websocket-2</a></li><li><a href="../html/38.chat-api-1.html">38.chat-api-1</a></li><li><a href="../html/38.chat-api-2.html">38.chat-api-2</a></li><li><a href="../html/38.chat-3.html">38.chat-3</a></li><li><a href="../html/38.chat-api-3.html">38.chat-api-3</a></li><li><a href="../html/38.chat.html">38.chat</a></li><li><a href="../html/38.chat2.html">38.chat2</a></li><li><a href="../html/38.chat2.html">38.chat2</a></li><li><a href="../html/39.crawl-0.html">39.crawl-0</a></li><li><a href="../html/39.crawl-1.html">39.crawl-1</a></li><li><a href="../html/39.crawl-2.html">39.crawl-2</a></li><li><a href="../html/40.deploy.html">40.deploy</a></li><li><a href="../html/41.safe.html">41.safe</a></li><li><a href="../html/42.test.html">42.test</a></li><li><a href="../html/43.nginx.html">43.nginx</a></li><li><a href="../html/44.enzyme.html">44.enzyme</a></li><li><a href="../html/45.docker.html">45.docker</a></li><li><a href="../html/46.elastic.html">46.elastic</a></li><li><a href="../html/47.oauth.html">47.oauth</a></li><li><a href="../html/48.wxpay.html">48.wxpay</a></li><li><a href="../html/49.nunjucks.html">49.nunjucks</a></li><li><a href="../html/50.ketang.html">50.ketang</a></li><li><a href="../html/index.html">index</a></li><li><a href="../html/51.typescript.html">51.typescript</a></li><li><a href="../html/52.UML.html">52.UML</a></li><li><a href="../html/53.design.html">53.design</a></li><li><a href="../html/index.html">index</a></li><li><a href="../html/54.linux.html">54.linux</a></li><li><a href="../html/55.yaml.html">55.yaml</a></li><li><a href="../html/50.ketang2.html">50.ketang2</a></li><li><a href="../html/56.ts.html">56.ts</a></li><li><a href="../html/57.ts_react.html">57.ts_react</a></li><li><a href="../html/58.react-ssr.html">58.react-ssr</a></li><li><a href="../html/59.react-ssr.html">59.react-ssr</a></li></ul></div>


<div class="warpper">

    <div class="page-toc">
        <ul><li><a href="#t01. 可执行脚本">1. 可执行脚本</a></li><li><a href="#t12. 命令行参数的原始写法">2. 命令行参数的原始写法</a></li><li><a href="#t23. 新建进程">3. 新建进程</a></li><li><a href="#t34. yargs">4. yargs</a><ul><li><a href="#t44.1 安装">4.1 安装</a></li><li><a href="#t54.2 读取命令行参数">4.2 读取命令行参数</a></li><li><a href="#t64.3 还可以指定别名">4.3 还可以指定别名</a></li><li><a href="#t74.4 下划线属性">4.4 下划线属性</a></li><li><a href="#t84.5 命令行参数的配置">4.5 命令行参数的配置</a></li><li><a href="#t94.6 帮助信息">4.6 帮助信息</a></li></ul></li></ul>
    </div>
    
    <div class="content markdown-body">
        <h2 id="t01. &#x53EF;&#x6267;&#x884C;&#x811A;&#x672C;">1. &#x53EF;&#x6267;&#x884C;&#x811A;&#x672C; <a href="#t01. &#x53EF;&#x6267;&#x884C;&#x811A;&#x672C;"> # </a></h2>
<p>&#x4F7F;&#x7528;Javascript&#x8BED;&#x8A00;&#x7F16;&#x5199;&#x4E00;&#x4E2A;&#x53EF;&#x6267;&#x884C;&#x811A;&#x672C;</p>
<pre><code class="lang-javascript"><span class="hljs-meta">#!/usr/bin/env node</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;hello&apos;</span>);
</code></pre>
<p>&#x7136;&#x540E;&#x4FEE;&#x6539;&#x6743;&#x9650;</p>
<pre><code class="lang-javascript">chmod <span class="hljs-number">755</span> hello
</code></pre>
<p>&#x6267;&#x884C;&#x811A;&#x672C;</p>
<pre><code class="lang-javascript">./hello
hello
</code></pre>
<p>&#x5982;&#x679C;&#x60F3;&#x628A;&#x8DEF;&#x5F84;&#x53BB;&#x6389;&#x53EF;&#x4EE5;&#x628A;hello&#x7684;&#x8DEF;&#x5F84;&#x52A0;&#x5165;&#x73AF;&#x5883;&#x53D8;&#x91CF;PATH&#x3002;&#x4F46;&#x662F;&#xFF0C;&#x53E6;&#x4E00;&#x79CD;&#x66F4;&#x597D;&#x7684;&#x505A;&#x6CD5;&#x65F6;&#x5728;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;package.json</p>
<pre><code class="lang-javascript">{
    <span class="hljs-attr">name</span>:<span class="hljs-string">&apos;hello&apos;</span>,
    <span class="hljs-string">&quot;bin&quot;</span>:{
        <span class="hljs-string">&quot;hello&quot;</span>:<span class="hljs-string">&quot;hello&quot;</span>
    }
}
</code></pre>
<p>&#x7136;&#x540E;npm link</p>
<pre><code class="lang-javascript">npm link
</code></pre>
<p>&#x5728;&#x6267;&#x884C;hello&#x5C31;&#x4E0D;&#x7528;&#x8F93;&#x5165;&#x8DEF;&#x5F84;&#x4E86;</p>
<pre><code class="lang-javascript">hello
</code></pre>
<h2 id="t12. &#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#x7684;&#x539F;&#x59CB;&#x5199;&#x6CD5;">2. &#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#x7684;&#x539F;&#x59CB;&#x5199;&#x6CD5; <a href="#t12. &#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#x7684;&#x539F;&#x59CB;&#x5199;&#x6CD5;"> # </a></h2>
<p> &#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x7528;&#x7CFB;&#x7EDF;&#x53D8;&#x91CF;<code>process.env</code>&#x83B7;&#x53D6;</p>
<pre><code class="lang-javascript"><span class="hljs-meta">#!/usr/bin/env node</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;hello &apos;</span>,process.argv[<span class="hljs-number">2</span>]);
</code></pre>
<pre><code>hello zfpx

process.env = [&apos;node&apos;,&apos;hello&apos;,&apos;zfpx&apos;]
</code></pre><h2 id="t23. &#x65B0;&#x5EFA;&#x8FDB;&#x7A0B;">3. &#x65B0;&#x5EFA;&#x8FDB;&#x7A0B; <a href="#t23. &#x65B0;&#x5EFA;&#x8FDB;&#x7A0B;"> # </a></h2>
<p>&#x811A;&#x672C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>child_process</code>&#x6A21;&#x5757;&#x65B0;&#x5EFA;&#x5B50;&#x8FDB;&#x7A0B;&#xFF0C;&#x4ECE;&#x800C;&#x6267;&#x884C;<code>linux</code>&#x547D;&#x4EE4;</p>
<pre><code class="lang-javascript"><span class="hljs-meta">#!/usr/bin/env node</span>
<span class="hljs-keyword">let</span> name = process.argv[<span class="hljs-number">2</span>];
<span class="hljs-keyword">let</span> {exec} = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;child_process&apos;</span>);
<span class="hljs-keyword">let</span> child  = exec(<span class="hljs-string">&apos;echo hello &apos;</span>+name,(err,stdout,stderr)=&gt;{
    <span class="hljs-keyword">if</span>(err) <span class="hljs-keyword">throw</span> err;
    <span class="hljs-built_in">console</span>.info(stdout);
});
</code></pre>
<pre><code class="lang-javascript">hello zfpx
</code></pre>
<h2 id="t34. yargs">4. yargs <a href="#t34. yargs"> # </a></h2>
<p>yargs&#x6A21;&#x5757;&#x80FD;&#x591F;&#x89E3;&#x51B3;&#x5982;&#x4F55;&#x5904;&#x7406;&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#x3002;</p>
<h3 id="t44.1 &#x5B89;&#x88C5;">4.1 &#x5B89;&#x88C5; <a href="#t44.1 &#x5B89;&#x88C5;"> # </a></h3>
<pre><code class="lang-javascript">npm install yargs --save
</code></pre>
<h3 id="t54.2 &#x8BFB;&#x53D6;&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;">4.2 &#x8BFB;&#x53D6;&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570; <a href="#t54.2 &#x8BFB;&#x53D6;&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;"> # </a></h3>
<p>yargs&#x6A21;&#x5757;&#x63D0;&#x4F9B;&#x4E86;argv&#x5BF9;&#x8C61;&#xFF0C;&#x7528;&#x6765;&#x8BFB;&#x53D6;&#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;</p>
<pre><code class="lang-javascript"><span class="hljs-meta">#!/usr/bin/env node</span>
<span class="hljs-keyword">let</span> argv = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;yargs&apos;</span>).argv;
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;hello &apos;</span>,argv.name);
</code></pre>
<pre><code class="lang-javascript">hello --name=zfpx
hello --name zfpx
</code></pre>
<blockquote>
<p>process.argv</p>
<pre><code>[ &apos;/usr/local/bin/node&apos;, &apos;/usr/local/bin/hello4&apos;, &apos;--name=zfpx&apos; ]
</code></pre></blockquote>
<blockquote>
<p>argv</p>
<pre><code>{
  name: &apos;zfpx&apos;,
}
</code></pre></blockquote>
<h3 id="t64.3 &#x8FD8;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x522B;&#x540D;">4.3 &#x8FD8;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x522B;&#x540D; <a href="#t64.3 &#x8FD8;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x522B;&#x540D;"> # </a></h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> argv = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;yargs&apos;</span>)
.alias(<span class="hljs-string">&apos;n&apos;</span>,<span class="hljs-string">&apos;name&apos;</span>)
.argv
</code></pre>
<pre><code class="lang-javascript">hello -n zfpx
hello --name zfpx
</code></pre>
<h3 id="t74.4 &#x4E0B;&#x5212;&#x7EBF;&#x5C5E;&#x6027;">4.4 &#x4E0B;&#x5212;&#x7EBF;&#x5C5E;&#x6027; <a href="#t74.4 &#x4E0B;&#x5212;&#x7EBF;&#x5C5E;&#x6027;"> # </a></h3>
<p>argv&#x5BF9;&#x8C61;&#x6709;&#x4E00;&#x4E2A;&#x4E0B;&#x5212;&#x7EBF;&#x5C5E;&#x6027;&#xFF0C;&#x53EF;&#x4EE5;&#x83B7;&#x53D6;&#x975E;&#x8FDE;&#x8BCD;&#x7EBF;&#x5F00;&#x5934;&#x7684;&#x53C2;&#x6570;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> argv = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;yargs&apos;</span>).argv
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;hello &apos;</span>,argv.n);
<span class="hljs-built_in">console</span>.log(argv._);
</code></pre>
<pre><code class="lang-javascript">hello A -n zfpx B C
hello zfpx [<span class="hljs-string">&apos;A&apos;</span>,<span class="hljs-string">&apos;B&apos;</span>,<span class="hljs-string">&apos;C&apos;</span>]
</code></pre>
<h3 id="t84.5 &#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#x7684;&#x914D;&#x7F6E;">4.5 &#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#x7684;&#x914D;&#x7F6E; <a href="#t84.5 &#x547D;&#x4EE4;&#x884C;&#x53C2;&#x6570;&#x7684;&#x914D;&#x7F6E;"> # </a></h3>
<ul>
<li>demand &#x662F;&#x5426;&#x5FC5;&#x9009;</li>
<li>default &#x9ED8;&#x8BA4;&#x503C;</li>
<li>describe &#x63D0;&#x793A;</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-meta">#!/usr/bin/env node</span>
<span class="hljs-keyword">let</span> argv = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;yargs&apos;</span>)
  .demand([<span class="hljs-string">&apos;n&apos;</span>])
  .default({<span class="hljs-attr">n</span>:<span class="hljs-string">&apos;zfpx&apos;</span>})
  .describe({<span class="hljs-attr">n</span>:<span class="hljs-string">&quot;&#x4F60;&#x7684;&#x540D;&#x5B57;&quot;</span>})
  .argv;
 <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;hello &apos;</span>,argv.n); 
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x4EE3;&#x8868;n&#x4E0D;&#x80FD;&#x7701;&#x7565;&#xFF0C;&#x9ED8;&#x8BA4;&#x503C;&#x4E3A;zfpx,&#x5E76;&#x7ED9;&#x51FA;&#x63D0;&#x793A;</p>
<p>option&#x65B9;&#x6CD5;&#x5141;&#x8BB8;&#x5C06;&#x6240;&#x6709;&#x7684;&#x914D;&#x7F6E;&#x5199;&#x5165;&#x914D;&#x7F6E;&#x5BF9;&#x8C61;</p>
<pre><code class="lang-javascript"><span class="hljs-meta">#!/usr/bin/env node</span>
<span class="hljs-keyword">let</span> argv = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;yargs&apos;</span>)
.option(<span class="hljs-string">&apos;n&apos;</span>,{
    <span class="hljs-attr">alias</span>:<span class="hljs-string">&apos;name&apos;</span>,
    <span class="hljs-attr">demand</span>:<span class="hljs-literal">true</span>,
    <span class="hljs-attr">default</span>:<span class="hljs-string">&apos;zfpx&apos;</span>,
    <span class="hljs-attr">describe</span>:<span class="hljs-string">&apos;&#x8BF7;&#x8F93;&#x5165;&#x4F60;&#x7684;&#x540D;&#x5B57;&apos;</span>,
    <span class="hljs-attr">type</span>:<span class="hljs-string">&apos;string&apos;</span>,
    <span class="hljs-attr">boolean</span>:<span class="hljs-literal">true</span>
}).argv
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;hello&apos;</span>,argv.n);
</code></pre>
<p>&#x6709;&#x65F6;&#x5019;&#xFF0C;&#x67D0;&#x4E9B;&#x53C2;&#x6570;&#x4E0D;&#x9700;&#x8981;&#xFF0C;&#x53EA;&#x8D77;&#x5230;&#x5F00;&#x5173;&#x4F5C;&#x7528;&#x3002;&#x53EF;&#x4EE5;&#x7528;boolean&#x6307;&#x5B9A;&#x8FD9;&#x4E9B;&#x53C2;&#x6570;&#x8FD4;&#x56DE;&#x5E03;&#x5C14;&#x503C;</p>
<pre><code class="lang-javascript"><span class="hljs-meta">#!/usr/bin/env node</span>
<span class="hljs-keyword">let</span> argv = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;yargs&apos;</span>)
    .boolean([<span class="hljs-string">&apos;private&apos;</span>])
    .argv
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;hello&apos;</span>,argv.n);    
</code></pre>
<p>&#x53C2;&#x6570;private&#x603B;&#x662F;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5E03;&#x5C14;&#x503C;</p>
<pre><code class="lang-javascript">hello 
<span class="hljs-literal">false</span>
hello -private
<span class="hljs-literal">true</span>
hello -private zfpx   
<span class="hljs-literal">true</span>
</code></pre>
<h3 id="t94.6 &#x5E2E;&#x52A9;&#x4FE1;&#x606F;">4.6 &#x5E2E;&#x52A9;&#x4FE1;&#x606F; <a href="#t94.6 &#x5E2E;&#x52A9;&#x4FE1;&#x606F;"> # </a></h3>
<p>yargs&#x6A21;&#x5757;&#x63D0;&#x4F9B;&#x4EE5;&#x4E0B;&#x65B9;&#x6CD5;&#xFF0C;&#x751F;&#x6210;&#x5E2E;&#x52A9;&#x4FE1;&#x606F;</p>
<ul>
<li>usage &#x7528;&#x6CD5;&#x683C;&#x5F0F;</li>
<li>example &#x63D0;&#x4F9B;&#x4F8B;&#x5B50;</li>
<li>help &#x663E;&#x793A;&#x5E2E;&#x52A9;&#x4FE1;&#x606F;</li>
<li>epilog &#x51FA;&#x73B0;&#x5728;&#x5E2E;&#x52A9;&#x4FE1;&#x606F;&#x7684;&#x7ED3;&#x5C3E;</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-meta">#!/usr/bin/env node</span>
<span class="hljs-keyword">let</span> argv = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;argv&apos;</span>)
  .option(<span class="hljs-string">&apos;n&apos;</span>,{
      <span class="hljs-attr">alias</span>:<span class="hljs-string">&apos;name&apos;</span>,
      <span class="hljs-attr">demand</span>:<span class="hljs-literal">true</span>,
      <span class="hljs-attr">default</span>:<span class="hljs-string">&apos;tom&apos;</span>,
      <span class="hljs-attr">describe</span>:<span class="hljs-string">&apos;&#x4F60;&#x7684;&#x540D;&#x5B57;&apos;</span>,
      <span class="hljs-attr">type</span>:<span class="hljs-string">&apos;string&apos;</span>
  })
  .usage(<span class="hljs-string">&apos;Usage: hello [options]&apos;</span>)
  .example(<span class="hljs-string">&apos;hello -n zfpx&apos;</span>,<span class="hljs-string">&apos;say hello to zfpx&apos;</span>)
  .help(<span class="hljs-string">&apos;h&apos;</span>)
  .alias(<span class="hljs-string">&apos;h&apos;</span>,<span class="hljs-string">&apos;help&apos;</span>)
  .epilog(<span class="hljs-string">&apos;copyright 2018&apos;</span>)
  .argv

</code></pre>

        <div class="copyright">Powered by <a href="https://github.com/jaywcjlove/idoc" target="_blank">idoc</a>. Dependence <a href="https://nodejs.org">Node.js</a> run.</div>
    </div>
    
</div>

<script src="https://cdn.bootcss.com/jquery/3.0.0/jquery.js"></script>
<script>
$('.warpper .page-toc ul ul li a').on('click',function(){
  $('.warpper .page-toc ul ul li a').removeClass('my-active')
  $(this).addClass('my-active')
})
  // if (!$('.understand-me').length) {
  //   var bar = $(window).height() - $('.navbar ').height() - $('.page-toc').position().top;
  //   var count = bar / 26 / 2;
  //   var barHeight = $('.page-toc').outerHeight();
  //   $('.page-toc li').eq(0).children('a').addClass('red');
  //   var arr = [];
  //   $("h1,h2,h3,h4,h5,h6").each(function () {
  //     arr.push($(this).position().top);
  //   });
  //   var timer
  //   function dark() {
  //     clearTimeout(timer)
  //      timer = setTimeout(function () {
  //      var top = Math.abs($('.page-toc > ul').position().top);
  //      var cur = $('.content').scrollTop();
  //      for (var i = arr.length; i >= 0; i--) {
  //        if (arr[i] <= cur) {
  //          break;
  //        }
  //      }
  //      if (i === -1) {
  //        i = 0;
  //      }
  //      $('.page-toc li a').removeClass('red');
  //      $('.page-toc li').eq(i).children('a').addClass('red');
  //      let height = $('.page-toc li').eq(i).position().top-$('.page-toc').height(); // 如果当前的offset出去了 回到中间可好？
  //      $('.page-toc').scrollTop(height+$('.page-toc').height()/2);
  //    },200)
  //   }

  //   $('.content').on('scroll', dark);
  // }
</script>
<style>

    /* ::-webkit-scrollbar{width:14px;}
    ::-webkit-scrollbar-track{background-color:transparent;}
    ::-webkit-scrollbar-thumb{background-color:transparent;}
    ::-webkit-scrollbar-thumb:hover {background-color:transparent}
    ::-webkit-scrollbar-thumb:active {background-color:transparent} */

    .page-toc > ul .red {
        background: #f3f3f3;
        z-index: 1;
        border-left: 3px solid #009a61;
        -webkit-transition: all .2s ease;
        transition: all .2s ease;
        color: #000
    }





</style>
</body>
</html>
